﻿/*
 * 更新鼠标样式、移动窗体、缩放窗体
*/


#ifndef WIDGETDATA_H
#define WIDGETDATA_H
#include <QWidget>
#include <QRubberBand>
#include <QEvent>
#include "cursorposcalculator.h"
#include "framelesshelperprivate.h"

class CursorPosCalculator;

class WidgetData
{
public:
    WidgetData(FrameLessHelperPrivate *_d, QWidget *pTopLevelWidget);
    ~WidgetData();
    QWidget* widget();

    void handleWidgetEvent(QEvent *event);

    void updateRubberBandStatus();

private:

    void updateCursorShape(const QPoint &gMousePos);

    void resizeWidget(const QPoint &gMousePos);

    void moveWidget(const QPoint &gMousePos);

    void handleMousePressEvent(QMouseEvent *event);

    void handleMouseReleaseEvent(QMouseEvent *event);

    void handleMouseMoveEvent(QMouseEvent *event);

    void handleLeaveEvent(QEvent *event);

    void handleHoverMoveEvent(QHoverEvent *event);

private:
    FrameLessHelperPrivate *d;
    QRubberBand *rubberBand;
    QWidget *widgetPtr;
    QPoint ptDragPos;
    CursorPosCalculator pressedMousePos;
    CursorPosCalculator moveMousePos;
    bool isLeftButtonPressed;
    bool isCursorShapeChanged;
    bool isLeftButtonTitlePressed;
    Qt::WindowFlags windowFlags;

};

#endif // WIDGETDATA_H
